package com.miyake.dsp.osa.lab.wrapper;

import com.miyake.dsp.common.CommonTool;
import com.miyake.dsp.converter.MovingAverageSetting;
import com.miyake.dsp.osa.lab.Calculator;
import com.miyake.dsp.osa.lab.LabUiAnnotation;
@LabUiAnnotation(caption="Median Filter")
public class MedianFilterWrapper extends Calculator {
	public static final String INPUT = "Input";
	public static final String OUTPUT = "Output";
	
	private MovingAverageSetting setting;

	public MedianFilterWrapper(MovingAverageSetting setting) {
		this.setting = setting;
		initInput(INPUT);
		initOutput(OUTPUT);
	}
	
	@Override
	public void process() {
		double[] in = getInput(INPUT).getRealPart();
		double[] out = CommonTool.getMedianFiltered(in, setting.getLength());
		setOutput(OUTPUT, out);
	}

	@Override
	public Object getSetting() {
		return this.setting;
	}

}
